package cn.faurecia.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import cn.faurecia.dto.WhItem;
import cn.faurecia.dto.WhStock;
import cn.faurecia.whitem.service.impl.WhItemServiceImpl;
import cn.faurecia.whstock.service.impl.WhStockServiceImpl;

@Controller
@RequestMapping("/outstock")
public class OutStockController{
  @Autowired
  private WhItemServiceImpl itemService;
  @Autowired
  private WhStockServiceImpl stockService;
  
  @RequestMapping("/toOutStock")
  public ModelAndView toOutStock(HttpServletResponse response, HttpServletRequest request, HttpSession session) {
    return new ModelAndView("/outstock");
  }
  @RequestMapping("/outstock")
  @ResponseBody
  public Map<String, Object> outstock(String param,HttpServletResponse response, HttpServletRequest request, HttpSession session) {
    Map<String, Object> map = new HashMap<String, Object>();
    if (param == null) {
      map.put("result", 1);
      map.put("msg", "出库失败");
      return map;
    }
    String[] itemCodes = param.split(";");
    map = stockService.outstock(itemCodes);
    return map;
  }
  
}
